#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   App_CommunicationControl_0x28_test.py
@Time    :   2022/08/29 13:31:28
@Author  :   YangLiang 
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

# here put the import lib
from pytest_assume.plugin import assume
 
import pytest
import logging
import time
import requests
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable

from sqlalchemy import false
sys.dont_write_bytecode = True

communicationControl = [([0x28,0x00, 0x01],[0x68,0x00]),         
                        ([0x28,0x03, 0x01],[0x68,0x03])
                        ]


communicationControl_NRC13 = [  ([0x28],[0x7F,0x28,0x13]),                    
                                ([0x28,0x00],[0x7F,0x28,0x13]),
                                ([0x28,0x01],[0x7F,0x28,0x13]),
                                ([0x28,0x03],[0x7F,0x28,0x13]),
                                ([0x28,0x00,0x01,0x15],[0x7F,0x28,0x13]),
                                ([0x28,0x00,0x03,0xFF],[0x7F,0x28,0x13]),  
                                ([0x28,0x01,0x01,0x25],[0x7F,0x28,0x13]),
                                ([0x28,0x01,0x03,0x06],[0x7F,0x28,0x13]), 
                                ([0x28,0x03,0x01,0x02],[0x7F,0x28,0x13]),
                                ([0x28,0x03,0x01,0xFF],[0x7F,0x28,0x13]),
                            ]

communicationControl_NRC12 = [  ([0x28,0x02,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x02,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x04,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x04,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x05,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x05,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x06,0x01],[0x7F,0x28,0x12]),        
                                ([0x28,0x06,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x3F,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x3F,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x40,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x40,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x5F,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x5F,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x60,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x60,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x7E,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x7E,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x7F,0x01],[0x7F,0x28,0x12]),         
                                ([0x28,0x7F,0x03],[0x7F,0x28,0x12]),
                                ([0x28,0x02,0x02],[0x7F,0x28,0x12]),
                                ([0x28,0x80,0x01],[0x7F,0x28,0x12]),
                                ([0x28,0x81,0x01],[0x7F,0x28,0x12]),
                                ([0x28,0x83,0x01],[0x7F,0x28,0x12]),
                                ([0x28,0x82,0x01],[0x7F,0x28,0x12]),
                                ([0x28,0x82,0x03],[0x7F,0x28,0x12]),
                            ]

communicationControl_NRC31 = [  ([0x28,0x00,0x02],[0x7F,0x28,0x31]),     
                                ([0x28,0x03,0x02],[0x7F,0x28,0x31]),
                                ([0x28,0x00,0x03],[0x7F,0x28,0x31]),             
                                ([0x28,0x03,0x03],[0x7F,0x28,0x31]),
                                ([0x28,0x00,0x04],[0x7F,0x28,0x31]),             
                                ([0x28,0x03,0x04],[0x7F,0x28,0x31]),
                                ([0x28,0x00,0x7F],[0x7F,0x28,0x31]),           
                                ([0x28,0x03,0x7F],[0x7F,0x28,0x31])
                            ]

communicationControl_NRC7F = [  ([0x28,0x00,0x01],[0x7F,0x28,0x7F]),         
                                ([0x28,0x03,0x01],[0x7F,0x28,0x7F]),
                                ]
class Test_CommunicationControl_Phy(object):

    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl]  
    @allure.severity('minor')
    @allure.title('Test 0x28 Response in Extended seession with physical addressing')
    @allure.description('Test  0x28 Response in Extended seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl,ids=ids)
    def test_CommunicationControl_Response_Extended_Phy(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)


    @allure.severity('normal')
    @allure.story('Communication Control Test')
    @allure.title('Test TxAndRx type of 0x28 in extended session with physical addressing')
    @allure.description('Test TxAndRx type of 0x28 in extended session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_Extended_Phy(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        logging.info('CommunicationControl disableRxAndTx')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        logging.info('CommunicationControl enableRxAndTx')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x00,0x01], [0x68,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
             
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 15 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 15 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

    @allure.severity('normal')
    @allure.title('Test TxAndRx type of 0x28 in change session with physical addressing')
    @allure.description('Test TxAndRx type of 0x28 in change session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_ChangeSessionToDefault_Phy(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10,0x01], [0x50,0x01], 0, iStep, False)
        time.sleep(2)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 15 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 15 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

    
    @allure.severity('normal')
    @allure.title('Test TxAndRx type of 0x28 in reset with physical addressing')
    @allure.description('Test TxAndRx type of 0x28 in reset with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_Reset_Extended_Phy(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11,0x01], [0x51,0x01], 0, iStep, False)
        time.sleep(2)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 1 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 1 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))


    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC7F]  
    @allure.severity('minor')
    @allure.title('Test NRC7F of 0x28 in default seession with physical addressing')
    @allure.description('Test NRC7F of 0x28 in default seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC7F,ids=ids)
    def test_CommunicationControl_NRC7F_Default_Phy(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False)


    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC7F]  
    @allure.severity('minor')
    @allure.title('Test NRC7F of 0x28 in programming seession with physical addressing')
    @allure.description('Test NRC7F of 0x28 in programming seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC7F,ids=ids)
    def test_CommunicationControl_NRC7F_Programming_Phy(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 2, iStep, False)


    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC12]   
    @allure.severity('minor') 
    @allure.title('Test NRC12 of 0x28 in Extended seession with physical addressing')        
    @allure.description('Test NRC12 of 0x28 in Extended seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC12,ids=ids)
    def test_CommunicationControl_NRC12_Extended_Phy(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC13]   
    @allure.severity('minor') 
    @allure.title('Test NRC13 of 0x28 in Extended seession with physical addressing')        
    @allure.description('Test NRC13 of 0x28 in Extended seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC13,ids=ids)
    def test_CommunicationControl_NRC13_Extended_Phy(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)

    
    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC31]   
    @allure.severity('minor') 
    @allure.title('Test NRC31 of 0x28 in Extended seession with physical addressing')        
    @allure.description('Test NRC31 of 0x28 in Extended seession with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC31,ids=ids)
    def test_CommunicationControl_NRC31_Extended_Phy(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False)



class Test_CommunicationControl_Fun(object):

    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl]  
    @allure.severity('minor')
    @allure.title('Test 0x28 Response in Extended seession with Functional addressing')
    @allure.description('Test  0x28 Response in Extended seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl,ids=ids)
    def test_CommunicationControl_Response_Extended_Fun(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')


    @allure.severity('normal')
    @allure.story('Communication Control Test')
    @allure.title('Test TxAndRx type of 0x28 in extended session with functional addressing')
    @allure.description('Test TxAndRx type of 0x28 in extended session with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_Extended_Fun(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        logging.info('CommunicationControl disableRxAndTx')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        logging.info('CommunicationControl enableRxAndTx')
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x00,0x01], [0x68,0x00], 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
             
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 15 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 15 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

    @allure.severity('normal')
    @allure.title('Test TxAndRx type of 0x28 in change session with functional addressing')
    @allure.description('Test TxAndRx type of 0x28 in change session with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_ChangeSessionToDefault_Fun(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x10,0x01], [0x50,0x01], 0, iStep, False)
        time.sleep(2)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 15 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 15 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))

    
    @allure.severity('normal')
    @allure.title('Test TxAndRx type of 0x28 in reset with functional addressing')
    @allure.description('Test TxAndRx type of 0x28 in reset with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_Reset_Extended_Fun(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False, 'UDSFun')
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        time.sleep(1)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 0, iStep, False)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 0 == fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 0 == fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x11,0x01], [0x51,0x01], 0, iStep, False)
        time.sleep(2)
        fps_06F = Driver['CAN'].get_fps(0x06F,'CAN')           # 获取ID为0x06F的帧数，用来判断是否停发使能了
        with assume: assert 1 < fps_06F
        logging.info('ID 06F fps---{}'.format(fps_06F))

        fps_050 = Driver['CAN'].get_fps(0x050,'CAN')
        with assume: assert 1 < fps_050
        logging.info('ID 050 fps---{}'.format(fps_050))


    @allure.severity('normal')
    @allure.title('Test TxAndRx type of 0x28 in change session with functional addressing')
    @allure.description('Test TxAndRx type of 0x28 in change session with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_CommunicationControl_StopRx_Fun(self,action,Driver):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x3E,0x00], [0x7E,0x00], 3, iStep, False)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False, 'UDSFun')
        time.sleep(1)
        # 设置车速>3kph
        Driver['CAN'].write_db_signal('CAKY_FRM', 'BCM', 'abs_sts_run1', 'abs_pm_veh_spd', 40)
        time.sleep(0.5)
        msg = Driver['CAN'].read_db_signal('CAKY_FRM', 'BCM', 'abs_sts_run1', 'abs_pm_veh_spd')
        logging.info('speed is:{0}'.format(msg))
        time.sleep(0.5)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x28,0x03,0x01], [0x68,0x03], 0, iStep, False, 'UDSFun')

        # 设置车速>3kph
        Driver['CAN'].write_db_signal('CAKY_FRM', 'BCM', 'abs_sts_run1', 'abs_pm_veh_spd', 0)
        time.sleep(0.5)
        msg = Driver['CAN'].read_db_signal('CAKY_FRM', 'BCM', 'abs_sts_run1', 'abs_pm_veh_spd')



    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC7F]  
    @allure.severity('minor')
    @allure.title('Test NRC7F of 0x28 in default seession with functional addressing')
    @allure.description('Test NRC7F of 0x28 in default seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC7F,ids=ids)
    def test_CommunicationControl_NRC7F_Default_Fun(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun')


    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC7F]  
    @allure.severity('minor')
    @allure.title('Test NRC7F of 0x28 in programming seession with functional addressing')
    @allure.description('Test NRC7F of 0x28 in programming seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC7F,ids=ids)
    def test_CommunicationControl_NRC7F_Programming_Fun(self,action,Driver,req, resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 2, iStep, False, 'UDSFun')


    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC12]   
    @allure.severity('minor') 
    @allure.title('Test NRC12 of 0x28 in Extended seession with functional addressing')        
    @allure.description('Test NRC12 of 0x28 in Extended seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC12,ids=ids)
    def test_CommunicationControl_NRC12_Extended_Fun(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')

    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC13]   
    @allure.severity('minor') 
    @allure.title('Test NRC13 of 0x28 in Extended seession with functional addressing')        
    @allure.description('Test NRC13 of 0x28 in Extended seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC13,ids=ids)
    def test_CommunicationControl_NRC13_Extended_Fun(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')

    
    ids = ['Request {0}'.format(binascii.b2a_hex(bytearray(req),' ')) for req,resp in communicationControl_NRC31]   
    @allure.severity('minor') 
    @allure.title('Test NRC31 of 0x28 in Extended seession with functional addressing')        
    @allure.description('Test NRC31 of 0x28 in Extended seession with functional addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    @pytest.mark.parametrize('req,resp',communicationControl_NRC31,ids=ids)
    def test_CommunicationControl_NRC31_Extended_Fun(self,action,Driver,req,resp):
        iStep = 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun')